package org.travel_system.controller;

import org.springframework.web.bind.annotation.*;
import org.travel_system.pojo.ComplaintHandLing;
import org.travel_system.service.ComplaintHandlingService;
import org.travel_system.service.UserService;
import org.travel_system.utils.Result;
import org.travel_system.utils.ThreadLocalUtil;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/complaintHandling")
public class ComplaintHandlingController {

    private final ComplaintHandlingService complaintHandlingService;



    public ComplaintHandlingController(ComplaintHandlingService complaintHandlingService) {
        this.complaintHandlingService = complaintHandlingService;
    }

    //查询处理结果
    @GetMapping("/{complaintId}")
    public Result<List<ComplaintHandLing>> getComplaintHandling(@PathVariable int complaintId) {
        return Result.success(complaintHandlingService.getComplaintHandling(complaintId));
    }

    //添加处理结果
    @PostMapping
    public Result<?> addComplaintHandling(@RequestBody ComplaintHandLing complaintHandLing) {
        return complaintHandlingService.addComplaintHandling(complaintHandLing) > 0 ?
                Result.success() :
                Result.error("添加失败");
    }

    //删除处理结果
    @DeleteMapping("/{handlingId}")
    public Result<?> deleteComplaintHandling(@PathVariable int handlingId) {
        return complaintHandlingService.deleteComplaintHandling(handlingId) > 0 ?
                Result.success() :
                Result.error("删除失败");
    }
}
